//
// Created by martin on 2/13/22.
//

#ifndef MUDUO_EXCEPTION_H
#define MUDUO_EXCEPTION_H

#include "muduo/base/Types.h"
#include <exception>

namespace muduo
{

/**
 * Basic Exception class with stack backtrace info.
 */
class Exception : public std::exception
{
public:
    Exception(string what);
    ~Exception() noexcept override = default;

    // default copy-ctor and operator= are okay.

    const char* what() const noexcept override
    {
        return message_.c_str();
    }

    const char* stackTrace() const noexcept
    {
        return stack_.c_str();
    }

private:
    string message_;
    string stack_;
};

} // namespace muduo

#endif //MUDUO_EXCEPTION_H
